<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <!-- <link rel="stylesheet" href="./bootstrap/css/bootstrap.min.css" /> -->
  </head>

  <body>
    <div id="app">
      <h2>Hello {{obj}}</h2>
      <button @click="obj.count++">count++</button>
      <button @click="obj.size.h++">size.h++</button>
      <button @click="obj.size.w++">size.w++</button>
      <button @click="obj.size={}">size={}</button>
    </div>
    <script type="module">
      import {
        createApp,
        ref,
        reactive,
        computed,
        watch,
      } from "./vue.esm-browser.js";
      const app = createApp({
        setup() {
          const obj = reactive({
            count: 10,
            size: {
              w: 200,
              h: 300,
            },
          });
          watch(obj, (newCount, oldCount) => {
            console.log(newCount, oldCount);
          });
          // watch(
          //   () => obj.size.h,
          //   (newCount, oldCount) => {
          //     console.log(newCount, oldCount);
          //   }
          // );
          // watch(
          //   () => obj.size.w,
          //   (newCount, oldCount) => {
          //     console.log(newCount, oldCount);
          //   }
          // );
          // watch(
          //   () => obj.size,
          //   (newCount, oldCount) => {
          //     console.log(newCount, oldCount);
          //   },
          //   { deep: true }
          // );
          return {
            obj,
          };
        },
      });

      app.mount("#app"); //挂载
    </script>
  </body>
</html>
